#include<iostream>
#include"ThreadPool.hpp"
#include"Task.hpp"
#include<memory>
#include<time.h>

int main()
{
    srand(time(nullptr)^getpid());
    EnableConsoleLogStrategy();

    // std::unique_ptr<ThreadPool<Task>> tp = std::make_unique<ThreadPool<Task>>(5);
    // tp->Start();
    
    int cnt=5;
    while(cnt--)
    {
        // 生产任务
        int x = rand()%10 + 1;
        usleep(rand()%73);
        int y = rand() % 5 + 1;
        Task t(x, y);

        // push到线程池中，处理
        // tp->Enqueue(t);
        ThreadPool<Task>::GetInstance()->Enqueue(t);
        sleep(1);
    }

    // tp->Stop();

    // tp->Wait();
    ThreadPool<Task>::GetInstance()->Stop();

    ThreadPool<Task>::GetInstance()->Wait();

    return  0;
}